import { reqUserLogin } from "@/api/index.js"
const state = {
  token: ''
}
const mutations = {
  USERLOGIN(state, token) {
    state.token = token
  }
}
const actions = {
  // 获取验证码

  // 用户登录[token]
  async userLogin( context ,data) {
    let res = await reqUserLogin(data)
    // console.log(res);
    if(res.code == 200) {
      context.commit("USERLOGIN",res.data.token)
      return 'ok'
    }else {
      return Promise.reject(new Error('fail'))
    }
  }
}
const getters = {}

export default {
  state,
  mutations,
  actions,
  getters
}